Skip to content

fix: move sembast to core#524

Open
frnandu wants to merge 5 commits intomasterfrom
fix-move-sembast-to-core
Open

fix: move sembast to core#524
frnandu wants to merge 5 commits intomasterfrom
fix-move-sembast-to-core

Conversation

@frnandu
Copy link
Collaborator

@frnandu frnandu commented Mar 24, 2026

Summary by CodeRabbit

  • Refactor
    • Sembast-backed cache manager is now provided from the core package and enabled only on non-web builds.
    • Sample app and tests updated to use the NDK-provided cache manager.
    • Standalone Sembast cache manager package (sources, docs, license, manifest) removed.
  • Chores
    • CI matrix narrowed to exclude the removed package.
  • Dependencies
    • Sample app no longer declares the standalone Sembast cache manager dependency.

@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Barrel exports in packages/ndk/lib/ndk.dart now conditionally export the Sembast cache manager for IO builds; the standalone packages/sembast_cache_manager package and its artifacts were removed. Examples, tests, and the sample app were updated to import the cache manager from package:ndk/...; CI matrix was narrowed.

Changes

Cohort / File(s) Summary
NDK exports & tests
packages/ndk/lib/ndk.dart, packages/ndk/test/data_layer/cache_manager/sembast_cache_manager_test.dart
Added conditional export for data_layer/repositories/cache_manager/sembast_cache_manager.dart guarded by if (dart.library.io); test imports updated to use package:ndk/... instead of the external package.
Examples
packages/ndk/example/sembast/sembast_cache_manager_example.dart
Replaced import of external sembast_cache_manager with the internal package:ndk/data_layer/repositories/cache_manager/sembast_cache_manager.dart; no logic changes.
Sample app
packages/sample-app/lib/main.dart, packages/sample-app/pubspec.yaml
Removed sembast_cache_manager dependency and local override from pubspec.yaml; main.dart now imports and constructs SembastCacheManager via package:ndk/... for non-web builds.
Removed external package
packages/sembast_cache_manager/...
Deleted the sembast_cache_manager package and its artifacts: pubspec.yaml, lib/sembast_cache_manager.dart, README.md, CHANGELOG.md, LICENSE, analysis_options.yaml, .gitignore, etc.
CI workflow
.github/workflows/test-dbs.yaml
Removed sembast_cache_manager from the workflow matrix so tests no longer run for that package.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 I hopped through code with whiskers bright,

Moved the cache beneath NDK's light.
One package folded, quiet and neat,
Now imports sing and tests keep beat. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: moving the sembast_cache_manager from an external package to being integrated into the NDK core library.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-move-sembast-to-core

Comment @coderabbitai help to get the list of available commands and usage tips.

@frnandu frnandu requested review from 1-leo and nogringo March 24, 2026 15:27
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/ndk/lib/ndk.dart`:
- Line 69: The root export in ndk.dart exposes
data_layer/repositories/cache_manager/sembast_cache_manager.dart which imports
dart:io and package:sembast/sembast_io.dart and breaks web consumers; fix by
removing the direct export and either (a) replace it with a conditional export
using the if (dart.library.io) syntax in ndk.dart to export
sembast_cache_manager for IO platforms and mem_cache_manager as the default, or
(b) move the Sembast implementation into a platform-specific entrypoint (e.g., a
new package:ndk/cache_managers/io.dart) and export only the web-safe
mem_cache_manager from the root barrel, ensuring references to
sembast_cache_manager.dart and mem_cache_manager are updated accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 00079ae6-7605-4ee3-82fa-532d102f5a8b

📥 Commits

Reviewing files that changed from the base of the PR and between b9db040 and 817569c.

⛔ Files ignored due to path filters (1)
  • packages/sample-app/pubspec.lock is excluded by !**/*.lock
📒 Files selected for processing (16)
  • packages/ndk/example/sembast/CLAUDE.md
  • packages/ndk/example/sembast/README.md
  • packages/ndk/example/sembast/sembast_cache_manager_example.dart
  • packages/ndk/lib/data_layer/repositories/cache_manager/ndk_extensions.dart
  • packages/ndk/lib/data_layer/repositories/cache_manager/sembast_cache_manager.dart
  • packages/ndk/lib/ndk.dart
  • packages/ndk/test/data_layer/cache_manager/sembast_cache_manager_test.dart
  • packages/sample-app/lib/main.dart
  • packages/sample-app/pubspec.yaml
  • packages/sembast_cache_manager/.gitignore
  • packages/sembast_cache_manager/CHANGELOG.md
  • packages/sembast_cache_manager/LICENSE
  • packages/sembast_cache_manager/README.md
  • packages/sembast_cache_manager/analysis_options.yaml
  • packages/sembast_cache_manager/lib/sembast_cache_manager.dart
  • packages/sembast_cache_manager/pubspec.yaml
💤 Files with no reviewable changes (10)
  • packages/sembast_cache_manager/LICENSE
  • packages/sembast_cache_manager/.gitignore
  • packages/sembast_cache_manager/CHANGELOG.md
  • packages/sembast_cache_manager/analysis_options.yaml
  • packages/sembast_cache_manager/lib/sembast_cache_manager.dart
  • packages/sample-app/lib/main.dart
  • packages/sembast_cache_manager/pubspec.yaml
  • packages/sample-app/pubspec.yaml
  • packages/sembast_cache_manager/README.md
  • packages/ndk/example/sembast/sembast_cache_manager_example.dart

@codecov
Copy link

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.24%. Comparing base (b9db040) to head (8a10dd6).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #524      +/-   ##
==========================================
+ Coverage   73.36%   74.24%   +0.88%     
==========================================
  Files         195      197       +2     
  Lines        8969     9561     +592     
==========================================
+ Hits         6580     7099     +519     
- Misses       2389     2462      +73     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/ndk/lib/ndk.dart (1)

47-47: Remove empty export statement.

export ''; is dead code that serves no purpose and should be removed.

🧹 Proposed fix
-export '';
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ndk/lib/ndk.dart` at line 47, Remove the dead empty export statement
`export '';` from the ndk.dart module; locate the line containing that exact
export in the ndk.dart file and delete it so the file does not contain a no-op
export.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/ndk/lib/ndk.dart`:
- Around line 69-70: The conditional export in ndk.dart currently points to the
same file for both branches, causing web builds to pull in dart:io; update the
export to provide a web-safe stub: change the export to use
'data_layer/repositories/cache_manager/sembast_cache_manager.dart' when
dart.library.io is true and to a new
'data_layer/repositories/cache_manager/sembast_cache_manager_stub.dart' when
false, and create that stub file implementing the same public API
(classes/functions) from sembast_cache_manager.dart but with bodies that throw
UnsupportedError (or no-op) on web so compilation succeeds; ensure public
symbols (e.g., the cache manager class and any factory functions) match names in
the original file.

---

Nitpick comments:
In `@packages/ndk/lib/ndk.dart`:
- Line 47: Remove the dead empty export statement `export '';` from the ndk.dart
module; locate the line containing that exact export in the ndk.dart file and
delete it so the file does not contain a no-op export.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f823dee4-3acf-451a-a099-a52aa106b49f

📥 Commits

Reviewing files that changed from the base of the PR and between 8351d00 and 8a10dd6.

📒 Files selected for processing (1)
  • packages/ndk/lib/ndk.dart

Comment on lines +69 to +70
export 'data_layer/repositories/cache_manager/sembast_cache_manager.dart'
if (dart.library.io) 'data_layer/repositories/cache_manager/sembast_cache_manager.dart';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check for dart:io and sembast_io imports in the sembast cache manager
fd -t f "sembast_cache_manager.dart" packages/ndk --exec head -50 {}

echo "---"
echo "Searching for dart:io imports:"
rg -n "dart:io|sembast_io" packages/ndk/lib/data_layer/repositories/cache_manager/

Repository: relaystr/ndk

Length of output: 2676


Conditional export with identical paths will break web builds.

The file sembast_cache_manager.dart imports dart:io and package:sembast/sembast_io.dart, which are unavailable on web. The current conditional export uses the same path for both conditions, so when dart.library.io is false (web builds), it still attempts to export sembast_cache_manager.dart, causing compilation failure.

Fix: Create a stub implementation for web or remove the unconditional default:

-export 'data_layer/repositories/cache_manager/sembast_cache_manager.dart'
-    if (dart.library.io) 'data_layer/repositories/cache_manager/sembast_cache_manager.dart';
+export 'data_layer/repositories/cache_manager/sembast_cache_manager_stub.dart'
+    if (dart.library.io) 'data_layer/repositories/cache_manager/sembast_cache_manager.dart';

Then create sembast_cache_manager_stub.dart with placeholder implementations that throw UnsupportedError if called on web.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ndk/lib/ndk.dart` around lines 69 - 70, The conditional export in
ndk.dart currently points to the same file for both branches, causing web builds
to pull in dart:io; update the export to provide a web-safe stub: change the
export to use 'data_layer/repositories/cache_manager/sembast_cache_manager.dart'
when dart.library.io is true and to a new
'data_layer/repositories/cache_manager/sembast_cache_manager_stub.dart' when
false, and create that stub file implementing the same public API
(classes/functions) from sembast_cache_manager.dart but with bodies that throw
UnsupportedError (or no-op) on web so compilation succeeds; ensure public
symbols (e.g., the cache manager class and any factory functions) match names in
the original file.

runs-on: ubuntu-latest
strategy:
matrix:
package: [sembast_cache_manager, objectbox, drift]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is sembast tested now?
Directly in the core package?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in same test package as mem_cache_manager_test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants